home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / OpenTransport.p < prev    next >
Encoding:
Text File  |  1996-02-13  |  56.6 KB  |  1,490 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTransport.p
  3.  
  4.      Contains:    OpenTransport interfaces
  5.  
  6.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10.  
  11. {$IFC UNDEFINED UsingIncludes}
  12. {$SETC UsingIncludes := 0}
  13. {$ENDC}
  14.  
  15. {$IFC NOT UsingIncludes}
  16.  UNIT OpenTransport;
  17.  INTERFACE
  18. {$ENDC}
  19.  
  20. {$IFC UNDEFINED __OPENTRANSPORT__}
  21. {$SETC __OPENTRANSPORT__ := 1}
  22.  
  23. {$I+}
  24. {$SETC OpenTransportIncludes := UsingIncludes}
  25. {$SETC UsingIncludes := 1}
  26.  
  27. {$SETC SystemSevenOrLater := 1}
  28.  
  29. {$IFC UNDEFINED __TYPES__}
  30. {$I Types.p}
  31. {$ENDC}
  32. {    ConditionalMacros.p                                            }
  33.  
  34. {$IFC UNDEFINED __MIXEDMODE__}
  35. {$I MixedMode.p}
  36. {$ENDC}
  37.  
  38. {$IFC UNDEFINED __STRINGS__}
  39. {$I Strings.p}
  40. {$ENDC}
  41.     
  42. TYPE
  43.     size_t = LONGINT;
  44.  
  45. {$SETC NULL := 0}
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.     uchar_p = LONGINT;
  51.  
  52.     ushort_p = LONGINT;
  53.  
  54.     short_p = LONGINT;
  55.  
  56.     char_p = LONGINT;
  57.  
  58.     boolean_p = LONGINT;
  59.  
  60. {$IFC UNDEFINED OTKERNEL }
  61. {$SETC OTKERNEL := 0}
  62. {$ENDC}
  63.  
  64. CONST
  65.     gestaltOpenTptVersions        = 'otvr';
  66.     gestaltOpenTpt                = 'otan';
  67.     gestaltOpenTptPresent        = $00000001;
  68.     gestaltOpenTptLoaded        = $00000002;
  69.     gestaltOpenTptAppleTalkPresent = $00000004;
  70.     gestaltOpenTptAppleTalkLoaded = $00000008;
  71.     gestaltOpenTptTCPPresent    = $00000010;
  72.     gestaltOpenTptTCPLoaded        = $00000020;
  73.     gestaltOpenTptIPXSPXPresent    = $00000040;
  74.     gestaltOpenTptIPXSPXLoaded    = $00000080;
  75.  
  76. {******************************************************************************
  77. ** Some prefixes for shared libraries
  78. *******************************************************************************}
  79.     kOTLibraryVersion    =    '1.0';
  80.     kOTLibraryPrefix    =    'OTLib$';
  81.     kOTModulePrefix    =    'OTModl$';
  82.     kOTKernelPrefix    =    'OTKrnl$';
  83.     kOTClientPrefix    =    'OTClnt$';
  84.     kOTSupportPrefix    =    'OTSupp$';
  85. {******************************************************************************
  86. ** Some typedefs used by the OpenTransport system
  87. *******************************************************************************}
  88. {    -------------------------------------------------------------------------
  89.     Miscellaneous typedefs
  90.     ------------------------------------------------------------------------- }
  91.     
  92. TYPE
  93.     OTTimeout = UInt32;
  94.  
  95.     OTSequence = LONGINT;
  96.  
  97.     OTNameID = LONGINT;
  98.  
  99.     OTReason = SInt32;
  100.  
  101.     OTQLen = UInt32;
  102.  
  103.     OTClient = Ptr;
  104.  
  105.     OTClientName = ^UInt8;
  106.  
  107.     OTOpenFlags = UInt32;
  108.  
  109.  
  110. CONST
  111.     O_ASYNC                        = $01;
  112.     O_NDELAY                    = $04;
  113.     O_NONBLOCK                    = $04;
  114.  
  115. {    -------------------------------------------------------------------------
  116.     StdCLib-style Error codes
  117.     ------------------------------------------------------------------------- }
  118.     
  119. TYPE
  120.     OTUnixErr = UInt16;
  121.  
  122. {
  123.          * There may be some error code confusions with other compiler vendor header
  124.          * files - However, these match both MPW and AIX definitions.
  125.          * We undefine the #defined ones we know about so that we can put them
  126.          * in an enum.
  127.          }
  128.  
  129. CONST
  130.     EPERM                        = 1;                            { Permission denied                    }
  131.     ENOENT                        = 2;                            { No such file or directory            }
  132.     ENORSRC                        = 3;                            { No such resource                        }
  133.     EINTR                        = 4;                            { Interrupted system service            }
  134.     EIO                            = 5;                            { I/O error                            }
  135.     ENXIO                        = 6;                            { No such device or address            }
  136.     EBADF                        = 9;                            { Bad file number                        }
  137.     EAGAIN                        = 11;                            { Try operation again later            }
  138.     ENOMEM                        = 12;                            { Not enough space                        }
  139.     EACCES                        = 13;                            { Permission denied                    }
  140.     EFAULT                        = 14;                            { Bad address                            }
  141.     EBUSY                        = 16;                            { Device or resource busy                }
  142.     EEXIST                        = 17;                            { File exists                            }
  143.     ENODEV                        = 19;                            { No such device                        }
  144.     EINVAL                        = 22;                            { Invalid argument                        }
  145.     ENOTTY                        = 25;                            { Not a character device                }
  146.     EPIPE                        = 32;                            { Broken pipe                            }
  147.     ERANGE                        = 34;                            { Math result not representable        }
  148.     EDEADLK                        = 35;                            { Call would block so was aborted        }
  149.     EWOULDBLOCK                    = EDEADLK;                        { Or a deadlock would occur            }
  150.     EALREADY                    = 37;
  151.     ENOTSOCK                    = 38;                            { Socket operation on non-socket        }
  152.     EDESTADDRREQ                = 39;                            { Destination address required            }
  153.     EMSGSIZE                    = 40;                            { Message too long                        }
  154.     EPROTOTYPE                    = 41;                            { Protocol wrong type for socket        }
  155.     ENOPROTOOPT                    = 42;                            { Protocol not available                }
  156.     EPROTONOSUPPORT                = 43;                            { Protocol not supported                }
  157.     ESOCKTNOSUPPORT                = 44;                            { Socket type not supported            }
  158.     EOPNOTSUPP                    = 45;                            { Operation not supported on socket    }
  159.     EADDRINUSE                    = 48;                            { Address already in use                }
  160.     EADDRNOTAVAIL                = 49;                            { Can't assign requested address        }
  161.     ENETDOWN                    = 50;                            { Network is down                        }
  162.     ENETUNREACH                    = 51;                            { Network is unreachable                }
  163.     ENETRESET                    = 52;                            { Network dropped connection on reset    }
  164.     ECONNABORTED                = 53;                            { Software caused connection abort        }
  165.     ECONNRESET                    = 54;                            { Connection reset by peer                }
  166.     ENOBUFS                        = 55;                            { No buffer space available            }
  167.     EISCONN                        = 56;                            { Socket is already connected            }
  168.     ENOTCONN                    = 57;                            { Socket is not connected                }
  169.     ESHUTDOWN                    = 58;                            { Can't send after socket shutdown        }
  170.     ETOOMANYREFS                = 59;                            { Too many references: can't splice    }
  171.     ETIMEDOUT                    = 60;                            { Connection timed out                    }
  172.     ECONNREFUSED                = 61;                            { Connection refused                    }
  173.     EHOSTDOWN                    = 64;                            { Host is down                            }
  174.     EHOSTUNREACH                = 65;                            { No route to host                        }
  175.     EPROTO                        = 70;
  176.     ETIME                        = 71;
  177.     ENOSR                        = 72;
  178.     EBADMSG                        = 73;
  179.     ECANCEL                        = 74;
  180.     ENOSTR                        = 75;
  181.     ENODATA                        = 76;
  182.     EINPROGRESS                    = 77;
  183.     ESRCH                        = 78;
  184.     ENOMSG                        = 79;
  185.     ELASTERRNO                    = 79;
  186.  
  187. {    -------------------------------------------------------------------------
  188.     Open Transport/XTI Error codes
  189.     ------------------------------------------------------------------------- }
  190.     
  191. TYPE
  192.     OTXTIErr = UInt16;
  193.  
  194.  
  195. CONST
  196.     TSUCCESS                    = 0;                            { No Error occurred                        }
  197.     TBADADDR                    = 1;                            { A Bad address was specified                }
  198.     TBADOPT                        = 2;                            { A Bad option was specified                }
  199.     TACCES                        = 3;                            { Missing access permission                }
  200.     TBADF                        = 4;                            { Bad provider reference                    }
  201.     TNOADDR                        = 5;                            { No address was specified                    }
  202.     TOUTSTATE                    = 6;                            { Call issued in wrong state                }
  203.     TBADSEQ                        = 7;                            { Sequence specified does not exist        }
  204.     TSYSERR                        = 8;                            { A system error occurred                    }
  205.     TLOOK                        = 9;                            { An event occurred - call Look()            }
  206.     TBADDATA                    = 10;                            { An illegal amount of data was specified    }
  207.     TBUFOVFLW                    = 11;                            { Passed buffer not big enough                }
  208.     TFLOW                        = 12;                            { Provider is flow-controlled                }
  209.     TNODATA                        = 13;                            { No data available for reading            }
  210.     TNODIS                        = 14;                            { No disconnect indication available        }
  211.     TNOUDERR                    = 15;                            { No Unit Data Error indication available    }
  212.     TBADFLAG                    = 16;                            { A Bad flag value was supplied            }
  213.     TNOREL                        = 17;                            { No orderly release indication available    }
  214.     TNOTSUPPORT                    = 18;                            { Command is not supported                    }
  215.     TSTATECHNG                    = 19;                            { State is changing - try again later        }
  216.     TNOSTRUCTYPE                = 20;                            { Bad structure type requested for OTAlloc    }
  217.     TBADNAME                    = 21;                            { A bad endpoint name was supplied            }
  218.     TBADQLEN                    = 22;                            { A Bind to an in-use address with qlen > 0}
  219.     TADDRBUSY                    = 23;                            { Address requested is already in use        }
  220.     TINDOUT                        = 24;                            { Accept failed because of pending listen    }
  221.     TPROVMISMATCH                = 25;                            { Tried to accept on incompatible endpoint    }
  222.     TRESQLEN                    = 26;
  223.     TRESADDR                    = 27;
  224.     TQFULL                        = 28;
  225.     TPROTO                        = 29;                            { An unspecified provider error occurred    }
  226.     TBADSYNC                    = 30;                            { A synchronous call at interrupt time        }
  227.     TCANCELED                    = 31;                            { The command was cancelled                }
  228.     TLASTXTIERROR                = 31;
  229.  
  230. {    -------------------------------------------------------------------------
  231.     Standard negative error codes conforming to both the Open Transport/XTI
  232.     errors and the Exxxxx StdCLib errors.
  233.     These are returned as OSStatus' from functions, and to the OTResult parameter
  234.     of a notification function or method.  However, OTResult may sometimes
  235.     contain other values depending on the notification.
  236.     ------------------------------------------------------------------------- }
  237.     
  238. TYPE
  239.     OTResult = SInt32;
  240.  
  241. {
  242.          * These map the Open Transport/XTI errors (the Txxxx error codes), and the
  243.          * StdCLib Exxxx error codes into unique spaces in the Apple OSStatus space.
  244.          }
  245.  
  246. CONST
  247.     kOTNoError                    = 0;                            { No Error occurred                        }
  248.     kOTOutOfMemoryErr            = 0+(-3199 - (ENOMEM));
  249.     kOTNotFoundErr                = 0+(-3199 - (ENOENT));
  250.     kOTDuplicateFoundErr        = 0+(-3199 - (EEXIST));
  251. {
  252.              * Remapped XTI error codes
  253.              }
  254.     kOTBadAddressErr            = 0+(-3149 - (TBADADDR));        { A Bad address was specified                }
  255.     kOTBadOptionErr                = 0+(-3149 - (TBADOPT));        { A Bad option was specified                }
  256.     kOTAccessErr                = 0+(-3149 - (TACCES));            { Missing access permission                }
  257.     kOTBadReferenceErr            = 0+(-3149 - (TBADF));            { Bad provider reference                    }
  258.     kOTNoAddressErr                = 0+(-3149 - (TNOADDR));        { No address was specified                    }
  259.     kOTOutStateErr                = 0+(-3149 - (TOUTSTATE));        { Call issued in wrong state                }
  260.     kOTBadSequenceErr            = 0+(-3149 - (TBADSEQ));        { Sequence specified does not exist        }
  261.     kOTSysErrorErr                = 0+(-3149 - (TSYSERR));        { A system error occurred                    }
  262.     kOTLookErr                    = 0+(-3149 - (TLOOK));            { An event occurred - call Look()            }
  263.     kOTBadDataErr                = 0+(-3149 - (TBADDATA));        { An illegal amount of data was specified    }
  264.     kOTBufferOverflowErr        = 0+(-3149 - (TBUFOVFLW));        { Passed buffer not big enough                }
  265.     kOTFlowErr                    = 0+(-3149 - (TFLOW));            { Provider is flow-controlled                }
  266.     kOTNoDataErr                = 0+(-3149 - (TNODATA));        { No data available for reading            }
  267.     kOTNoDisconnectErr            = 0+(-3149 - (TNODIS));            { No disconnect indication available        }
  268.     kOTNoUDErrErr                = 0+(-3149 - (TNOUDERR));        { No Unit Data Error indication available    }
  269.     kOTBadFlagErr                = 0+(-3149 - (TBADFLAG));        { A Bad flag value was supplied            }
  270.     kOTNoReleaseErr                = 0+(-3149 - (TNOREL));            { No orderly release indication available    }
  271.     kOTNotSupportedErr            = 0+(-3149 - (TNOTSUPPORT));    { Command is not supported                    }
  272.     kOTStateChangeErr            = 0+(-3149 - (TSTATECHNG));        { State is changing - try again later        }
  273.     kOTNoStructureTypeErr        = 0+(-3149 - (TNOSTRUCTYPE));    { Bad structure type requested for OTAlloc    }
  274.     kOTBadNameErr                = 0+(-3149 - (TBADNAME));        { A bad endpoint name was supplied            }
  275.     kOTBadQLenErr                = 0+(-3149 - (TBADQLEN));        { A Bind to an in-use addr with qlen > 0    }
  276.     kOTAddressBusyErr            = 0+(-3149 - (TADDRBUSY));        { Address requested is already in use        }
  277.     kOTIndOutErr                = 0+(-3149 - (TINDOUT));        { Accept failed because of pending listen    }
  278.     kOTProviderMismatchErr        = 0+(-3149 - (TPROVMISMATCH));    { Tried to accept on incompatible endpoint    }
  279.     kOTResQLenErr                = 0+(-3149 - (TRESQLEN));
  280.     kOTResAddressErr            = 0+(-3149 - (TRESADDR));
  281.     kOTQFullErr                    = 0+(-3149 - (TQFULL));
  282.     kOTProtocolErr                = 0+(-3149 - (TPROTO));            { An unspecified provider error occurred    }
  283.     kOTBadSyncErr                = 0+(-3149 - (TBADSYNC));        { A synchronous call at interrupt time        }
  284.     kOTCanceledErr                = 0+(-3149 - (TCANCELED));        { The command was cancelled                }
  285. {
  286.              * Remapped StdCLib error codes. %%% Remove ones we don't actually return.
  287.              }
  288.     kEPERMErr                    = 0+(-3199 - (EPERM));            { Permission denied                    }
  289.     kENOENTErr                    = 0+(-3199 - (ENOENT));            { No such file or directory            }
  290.     kENORSRCErr                    = 0+(-3199 - (ENORSRC));        { No such resource                        }
  291.     kEINTRErr                    = 0+(-3199 - (EINTR));            { Interrupted system service            }
  292.     kEIOErr                        = 0+(-3199 - (EIO));            { I/O error                            }
  293.     kENXIOErr                    = 0+(-3199 - (ENXIO));            { No such device or address            }
  294.     kEBADFErr                    = 0+(-3199 - (EBADF));            { Bad file number                        }
  295.     kEAGAINErr                    = 0+(-3199 - (EAGAIN));            { Try operation again later            }
  296.     kENOMEMErr                    = 0+(-3199 - (ENOMEM));            { Not enough space                        }
  297.     kEACCESErr                    = 0+(-3199 - (EACCES));            { Permission denied                    }
  298.     kEFAULTErr                    = 0+(-3199 - (EFAULT));            { Bad address                            }
  299.     kEBUSYErr                    = 0+(-3199 - (EBUSY));            { Device or resource busy                }
  300.     kEEXISTErr                    = 0+(-3199 - (EEXIST));            { File exists                            }
  301.     kENODEVErr                    = 0+(-3199 - (ENODEV));            { No such device                        }
  302.     kEINVALErr                    = 0+(-3199 - (EINVAL));            { Invalid argument                        }
  303.     kENOTTYErr                    = 0+(-3199 - (ENOTTY));            { Not a character device                }
  304.     kEPIPEErr                    = 0+(-3199 - (EPIPE));            { Broken pipe                            }
  305.     kERANGEErr                    = 0+(-3199 - (ERANGE));            { Message size too large for STREAM    }
  306.     kEWOULDBLOCKErr                = 0+(-3199 - (EWOULDBLOCK));    { Call would block, so was aborted        }
  307.     kEDEADLKErr                    = 0+(-3199 - (EDEADLK));        { or a deadlock would occur            }
  308.     kEALREADYErr                = 0+(-3199 - (EALREADY));
  309.     kENOTSOCKErr                = 0+(-3199 - (ENOTSOCK));        { Socket operation on non-socket        }
  310.     kEDESTADDRREQErr            = 0+(-3199 - (EDESTADDRREQ));    { Destination address required            }
  311.     kEMSGSIZEErr                = 0+(-3199 - (EMSGSIZE));        { Message too long                        }
  312.     kEPROTOTYPEErr                = 0+(-3199 - (EPROTOTYPE));        { Protocol wrong type for socket        }
  313.     kENOPROTOOPTErr                = 0+(-3199 - (ENOPROTOOPT));    { Protocol not available                }
  314.     kEPROTONOSUPPORTErr            = 0+(-3199 - (EPROTONOSUPPORT)); { Protocol not supported                }
  315.     kESOCKTNOSUPPORTErr            = 0+(-3199 - (ESOCKTNOSUPPORT)); { Socket type not supported            }
  316.     kEOPNOTSUPPErr                = 0+(-3199 - (EOPNOTSUPP));        { Operation not supported on socket    }
  317.     kEADDRINUSEErr                = 0+(-3199 - (EADDRINUSE));        { Address already in use                }
  318.     kEADDRNOTAVAILErr            = 0+(-3199 - (EADDRNOTAVAIL));    { Can't assign requested address        }
  319.     kENETDOWNErr                = 0+(-3199 - (ENETDOWN));        { Network is down                        }
  320.     kENETUNREACHErr                = 0+(-3199 - (ENETUNREACH));    { Network is unreachable                }
  321.     kENETRESETErr                = 0+(-3199 - (ENETRESET));        { Network dropped connection on reset    }
  322.     kECONNABORTEDErr            = 0+(-3199 - (ECONNABORTED));    { Software caused connection abort        }
  323.     kECONNRESETErr                = 0+(-3199 - (ECONNRESET));        { Connection reset by peer                }
  324.     kENOBUFSErr                    = 0+(-3199 - (ENOBUFS));        { No buffer space available            }
  325.     kEISCONNErr                    = 0+(-3199 - (EISCONN));        { Socket is already connected            }
  326.     kENOTCONNErr                = 0+(-3199 - (ENOTCONN));        { Socket is not connected                }
  327.     kESHUTDOWNErr                = 0+(-3199 - (ESHUTDOWN));        { Can't send after socket shutdown        }
  328.     kETOOMANYREFSErr            = 0+(-3199 - (ETOOMANYREFS));    { Too many references: can't splice    }
  329.     kETIMEDOUTErr                = 0+(-3199 - (ETIMEDOUT));        { Connection timed out                    }
  330.     kECONNREFUSEDErr            = 0+(-3199 - (ECONNREFUSED));    { Connection refused                    }
  331.     kEHOSTDOWNErr                = 0+(-3199 - (EHOSTDOWN));        { Host is down                            }
  332.     kEHOSTUNREACHErr            = 0+(-3199 - (EHOSTUNREACH));    { No route to host                        }
  333.     kEPROTOErr                    = 0+(-3199 - (EPROTO));
  334.     kETIMEErr                    = 0+(-3199 - (ETIME));
  335.     kENOSRErr                    = 0+(-3199 - (ENOSR));
  336.     kEBADMSGErr                    = 0+(-3199 - (EBADMSG));
  337.     kECANCELErr                    = 0+(-3199 - (ECANCEL));
  338.     kENOSTRErr                    = 0+(-3199 - (ENOSTR));
  339.     kENODATAErr                    = 0+(-3199 - (ENODATA));
  340.     kEINPROGRESSErr                = 0+(-3199 - (EINPROGRESS));
  341.     kESRCHErr                    = 0+(-3199 - (ESRCH));
  342.     kENOMSGErr                    = 0+(-3199 - (ENOMSG));
  343.     kOTClientNotInittedErr        = 0+(-3199 - (ELASTERRNO + 1));
  344.     kOTPortHasDiedErr            = 0+(-3199 - (ELASTERRNO + 2));
  345.     kOTPortWasEjectedErr        = 0+(-3199 - (ELASTERRNO + 3));
  346.     kOTBadConfigurationErr        = 0+(-3199 - (ELASTERRNO + 4));
  347.     kOTConfigurationChangedErr    = 0+(-3199 - (ELASTERRNO + 5));
  348.     kOTUserRequestedErr            = 0+(-3199 - (ELASTERRNO + 6));
  349.     kOTPortLostConnection        = 0+(-3199 - (ELASTERRNO + 7));
  350.  
  351. {    -------------------------------------------------------------------------
  352.     OTAddressType - defines the address type for the OTAddress
  353.     ------------------------------------------------------------------------- }
  354.     
  355. TYPE
  356.     OTAddressType = UInt16;
  357.  
  358.  
  359. CONST
  360.     kOTGenericName                = 0;
  361.  
  362. {    -------------------------------------------------------------------------
  363.     OTAddress - Generic OpenTransport protocol address
  364.     ------------------------------------------------------------------------- }
  365.  
  366. TYPE
  367.     OTAddress = RECORD
  368.         fAddressType:            OTAddressType;
  369.         fAddress:                PACKED ARRAY [0..0] OF SInt8; (* UInt8 *)
  370.     END;
  371.  
  372. {    -------------------------------------------------------------------------
  373.     OTStructType - defines the structure type for the OTAlloc call
  374.     ------------------------------------------------------------------------- }
  375.     OTStructType = UInt32;
  376.  
  377.  
  378. CONST
  379.     T_BIND                        = 1;
  380.     T_OPTMGMT                    = 2;
  381.     T_CALL                        = 3;
  382.     T_DIS                        = 4;
  383.     T_UNITDATA                    = 5;
  384.     T_UDERROR                    = 6;
  385.     T_INFO                        = 7;
  386.     T_REPLYDATA                    = 8;
  387.     T_REQUESTDATA                = 9;
  388.     T_UNITREQUEST                = 10;
  389.     T_UNITREPLY                    = 11;
  390.  
  391. {    -------------------------------------------------------------------------
  392.     OTFlags - flags for sending and receiving data
  393.     ------------------------------------------------------------------------- }
  394.     
  395. TYPE
  396.     OTFlags = UInt32;
  397.  
  398.  
  399. CONST
  400.     T_MORE                        = $001;                            { More data to come in message        }
  401.     T_EXPEDITED                    = $002;                            { Data is expedited, if possible    }
  402.     T_ACKNOWLEDGED                = $004;                            { Acknowledge transaction            }
  403.     T_PARTIALDATA                = $008;                            { Partial data - more coming        }
  404.     T_NORECEIPT                    = $010;                            { No event on transaction done        }
  405.  
  406. {    -------------------------------------------------------------------------
  407.     OTBand - a band value when reading priority messages
  408.     ------------------------------------------------------------------------- }
  409.     
  410. TYPE
  411.     OTBand = UInt32;
  412.  
  413. {    -------------------------------------------------------------------------
  414.     Reference values
  415.     ------------------------------------------------------------------------- }
  416.     StreamRef = Ptr;
  417.  
  418.     ProviderRef = Ptr;
  419.  
  420.     EndpointRef = Ptr;
  421.  
  422.     MapperRef = Ptr;
  423.  
  424.  
  425. CONST
  426.     kOTInvalidRef                = 0;
  427.     kOTInvalidStreamRef            = 0;
  428.     kOTInvalidProviderRef        = 0;
  429.     kOTInvalidEndpointRef        = 0;
  430.     kOTInvalidMapperRef            = 0;
  431.  
  432. {    -------------------------------------------------------------------------
  433.     OTEventCode values for Open Transport - These are the event codes that
  434.     are sent to notification routine during asynchronous processing.
  435.     ------------------------------------------------------------------------- }
  436.     
  437. TYPE
  438.     OTEventCode = UInt32;
  439.  
  440. {
  441.      * Function definition to handle notification from providers
  442.      }
  443.     OTNotifyProcPtr = ProcPtr;  { PROCEDURE (contextPtr: UNIV Ptr; code: OTEventCode; result: OTResult; cookie: UNIV Ptr); }
  444.  
  445.  
  446. CONST
  447. {
  448.          * These will be returned by the T_LOOK function, or will be returned
  449.          * if asynchronous notification is used.
  450.          }
  451.     T_LISTEN                    = $0001;                        { An connection request is available     }
  452.     T_CONNECT                    = $0002;                        { Confirmation of a connect request    }
  453.     T_DATA                        = $0004;                        { Standard data is available            }
  454.     T_EXDATA                    = $0008;                        { Expedited data is available            }
  455.     T_DISCONNECT                = $0010;                        { A disconnect is available            }
  456.     T_ERROR                        = $0020;                        { obsolete/unused in library            }
  457.     T_UDERR                        = $0040;                        { A Unit Data Error has occurred        }
  458.     T_ORDREL                    = $0080;                        { An orderly release is available        }
  459.     T_GODATA                    = $0100;                        { Flow control lifted on standard data    }
  460.     T_GOEXDATA                    = $0200;                        { Flow control lifted on expedited data}
  461.     T_REQUEST                    = $0400;                        { An Incoming request is available        }
  462.     T_REPLY                        = $0800;                        { An Incoming reply is available        }
  463.     T_PASSCON                    = $1000;                        { State is now T_DATAXFER                }
  464.     T_RESET                        = $2000;                        { Protocol has been reset                }
  465. {
  466.          * kPRIVATEEVENT + 1 through kPRIVATEEVENT + 0xffff
  467.          *        may be used for any private event codes desired.
  468.          *        All other event codes are reserved for Apple Computer, Inc.
  469.          *        use only.
  470.          }
  471.     kPRIVATEEVENT                = $10000000;
  472. {
  473.          * These are only returned if asynchronous notification is being used
  474.          }
  475.     kCOMPLETEEVENT                = $20000000;
  476.     T_BINDCOMPLETE                = $20000001;                    { Bind call is complete                }
  477.     T_UNBINDCOMPLETE            = $20000002;                    { Unbind call is complete                }
  478.     T_ACCEPTCOMPLETE            = $20000003;                    { Accept call is complete                }
  479.     T_REPLYCOMPLETE                = $20000004;                    { SendReply call is complete            }
  480.     T_DISCONNECTCOMPLETE        = $20000005;                    { Disconnect call is complete            }
  481.     T_OPTMGMTCOMPLETE            = $20000006;                    { OptMgmt call is complete                }
  482.     T_OPENCOMPLETE                = $20000007;                    { An Open call is complete                }
  483.     T_GETPROTADDRCOMPLETE        = $20000008;                    { GetProtAddress call is complete        }
  484.     T_RESOLVEADDRCOMPLETE        = $20000009;                    { A ResolveAddress call is complet        }
  485.     T_GETINFOCOMPLETE            = $2000000A;                    { A GetInfo call is complete            }
  486.     T_SYNCCOMPLETE                = $2000000B;                    { A Sync call is complete                }
  487.     T_MEMORYRELEASED            = $2000000C;                    { No-copy memory was released            }
  488.     T_REGNAMECOMPLETE            = $2000000D;                    { A RegisterName call is complete        }
  489.     T_DELNAMECOMPLETE            = $2000000E;                    { A DeleteName call is complete        }
  490.     T_LKUPNAMECOMPLETE            = $2000000F;                    { A LookupName call is complete        }
  491.     T_LKUPNAMERESULT            = $20000010;                    { A LookupName is returning a name        }
  492. {
  493.          * Events for streams - not normally seen by clients.
  494.          }
  495.     kSTREAMEVENT                = $21000000;
  496.     kOTDisablePortEvent            = $21000001;                    { this line deleted for release disk    }
  497.     kGetmsgEvent                = $21000002;                    { A GetMessage call is complete        }
  498.     kStreamReadEvent            = $21000003;                    { A Read call is complete                }
  499.     kStreamWriteEvent            = $21000004;                    { A Write call is complete                }
  500.     kStreamIoctlEvent            = $21000005;                    { An Ioctl call is complete            }
  501.     kStreamOpenEvent            = $21000007;                    { An OpenStream call is complete        }
  502.     kPollEvent                    = $21000008;                    { A Poll call is complete                }
  503.     kSIGNALEVENT                = $22000000;                    { A signal has arrived from the STREAM    }
  504.     kPROTOCOLEVENT                = $23000000;                    { Some event from the protocols        }
  505.     kIMMEDIATEEVENT                = $80000000;                    { This bit or'd in makes it "immediate"}
  506. {
  507.          * These are miscellaneous events that could be sent to a provider
  508.          }
  509.     kOTProviderIsDisconnected    = $23000001;                    { Provider is temporarily off-line        }
  510.     kOTProviderIsReconnected    = $23000002;                    { Provider is now back on-line            }
  511. {
  512.          * These are system events sent to each provider.
  513.          }
  514.     kOTProviderWillClose        = $24000001;                    { Provider will close immediately        }
  515.     kOTProviderIsClosed            = $24000002;                    { Provider was closed                    }
  516. {
  517.          * These are system events sent to registered clients
  518.              *
  519.             * result code is 0, cookie is the OTPortRef
  520.          }
  521.     kOTPortDisabled                = $25000001;                    { Port is now disabled                    }
  522.     kOTPortEnabled                = $25000002;                    { Port is now enabled                    }
  523.     kOTRequestHardware            = $25000003;                    { Request to use hardware                }
  524.     kOTHardwareInUse            = $25000003;                    { specified hardware is in use            }
  525.     kOTReleaseHardware            = $25000004;                    { Release use of hardware                }
  526.     kOTHardwareIsFree            = $25000004;                    { specified hardware is no longer used    }
  527. {
  528.              * A new port has been registered, cookie is the OTPortRef
  529.              }
  530.     kOTNewPortRegistered        = $25000003;                    { New port has been registered            }
  531. {
  532.              * result is a reason for the close request, cookie is a pointer to the 
  533.              * OTPortCloseStruct structure.
  534.              }
  535.     kOTClosePortRequest            = $25000005;                    { Request to close                        }
  536. {
  537.          * These are events sent to the configuration management infrastructure 
  538.          }
  539.     kOTConfigurationChanged        = $26000001;                    { Protocol configuration changed        }
  540.     kOTSystemSleep                = $26000002;
  541.     kOTSystemShutdown            = $26000003;
  542.     kOTSystemAwaken                = $26000004;
  543.     kOTSystemIdle                = $26000005;
  544.  
  545.     SIGHUP                        = 1;
  546.     SIGURG                        = 16;
  547.     SIGPOLL                        = 30;
  548.  
  549. {    -------------------------------------------------------------------------
  550.     Option Management equates
  551.     ------------------------------------------------------------------------- }
  552. {
  553.     ** The XTI Level number of a protocol
  554.     }
  555.     
  556. TYPE
  557.     OTXTILevel = UInt32;
  558.  
  559.  
  560. CONST
  561.     XTI_GENERIC                    = $ffff;                        { level to match any protocol    }
  562.  
  563. {
  564.     ** The XTI name of a protocol option
  565.     }
  566.     
  567. TYPE
  568.     OTXTIName = UInt32;
  569.  
  570. {
  571.          * XTI names for options used with XTI_GENERIC above
  572.          }
  573.  
  574. CONST
  575.     XTI_DEBUG                    = $0001;
  576.     XTI_LINGER                    = $0080;
  577.     XTI_RCVBUF                    = $1002;
  578.     XTI_RCVLOWAT                = $1004;
  579.     XTI_SNDBUF                    = $1001;
  580.     XTI_SNDLOWAT                = $1003;
  581.     XTI_PROTOTYPE                = $1005;
  582.  
  583. {
  584.          * Generic options that can be used with any protocol
  585.          * that understands them
  586.          }
  587.     OPT_CHECKSUM                = $0600;                        { Set checksumming = UInt32 - 0 or 1)}
  588.     OPT_RETRYCNT                = $0601;                        { Set a retry counter = UInt32 (0 = infinite)}
  589.     OPT_INTERVAL                = $0602;                        { Set a retry interval = UInt32 milliseconds}
  590.     OPT_ENABLEEOM                = $0603;                        { Enable the EOM indication = UInt8 (0 or 1)}
  591.     OPT_SELFSEND                = $0604;                        { Enable Self-sending on broadcasts = UInt32 (0 or 1)}
  592.     OPT_SERVERSTATUS            = $0605;                        { Set Server Status (format is proto dependent)}
  593.     OPT_KEEPALIVE                = $0008;                        { See t_keepalive structure}
  594.  
  595. {******************************************************************************
  596. ** Definitions not associated with a Typedef
  597. *******************************************************************************}
  598. {    -------------------------------------------------------------------------
  599.     IOCTL values for the OpenTransport system
  600.     ------------------------------------------------------------------------- }
  601.     MIOC_STREAMIO                = 'A';                            { Basic Stream ioctl() cmds - I_PUSH, I_LOOK, etc. }
  602.     MIOC_STRLOG                    = 'b';                            { ioctl's for Mentat's log device }
  603.     MIOC_SAD                    = 'g';                            { ioctl's for Mentat's sad module }
  604.     MIOC_ARP                    = 'h';                            { ioctl's for Mentat's arp module }
  605.     MIOC_TCP                    = 'k';                            { tcp.h ioctl's }
  606.     MIOC_DLPI                    = 'l';                            { dlpi.h additions }
  607.     MIOC_OT                        = 'O';                            { ioctls for Open Transport    }
  608.     MIOC_ATALK                    = 'T';                            { ioctl's for AppleTalk    }
  609.     MIOC_SRL                    = 'U';                            { ioctl's for Serial        }
  610.     MIOC_SRL_HIGH                = $5400;                        { ioctls for Serial            'U' << 8 }
  611.     MIOC_OT_HIGH                = $4F00;                        { ioctls for Open Transport    'O' << 8 }
  612.     MIOC_SIO_HIGH                = $4100;                        { ioctls for StreamIO            'A' << 8 }
  613.  
  614.     I_STR                        = 0+(MIOC_SIO_HIGH + 8);
  615.     I_FIND                        = 0+(MIOC_SIO_HIGH + 11);
  616.     I_LIST                        = 0+(MIOC_SIO_HIGH + 22);
  617.     I_OTGetMiscellaneousEvents    = 0+(MIOC_OT_HIGH + 1);
  618.     I_OTSetFramingType            = 0+(MIOC_OT_HIGH + 2);
  619.     kOTGetFramingValue            = $ffffffff;
  620.     I_OTSetRawMode                = 0+(MIOC_OT_HIGH + 3);
  621.  
  622.      * structure of ioctl data for I_STR IOCtls
  623.      }
  624.  
  625. TYPE
  626.     strioctl = RECORD
  627.         ic_cmd:                    LONGINT;                                { downstream command    }
  628.         ic_timout:                LONGINT;                                { ACK/NAK timeout        }
  629.         ic_len:                    LONGINT;                                { length of data arg    }
  630.         ic_dp:                    ^CHAR;                                    { ptr to data arg        }
  631.     END;
  632.  
  633. {    -------------------------------------------------------------------------
  634.     Maximum size of a provider name, and maximum size of a STREAM module name.
  635.     This module name is smaller than the maximum size of a TProvider to allow
  636.     for 4 characters of extra "minor number" information that might be 
  637.     potentially in a TProvider name
  638.     ------------------------------------------------------------------------- }
  639.  
  640. CONST
  641.     kMaxModuleNameLength        = 31;
  642.     kMaxModuleNameSize            = kMaxModuleNameLength + 1;
  643.     kMaxProviderNameLength        = kMaxModuleNameLength + 4;
  644.     kMaxProviderNameSize        = kMaxProviderNameLength + 1;
  645.     kMaxSlotIDLength            = 7;
  646.     kMaxSlotIDSize                = 8;
  647.     kMaxResourceInfoLength        = 31;
  648.     kMaxResourceInfoSize        = 32;
  649.  
  650. {    -------------------------------------------------------------------------
  651.     These values are used in the "fields" parameter of the OTAlloc call
  652.     to define which fields of the structure should be allocated.
  653.     ------------------------------------------------------------------------- }
  654.     T_ADDR                        = $01;
  655.     T_OPT                        = $02;
  656.     T_UDATA                        = $04;
  657.     T_ALL                        = $ffff;
  658.  
  659. {    -------------------------------------------------------------------------
  660.     These are the potential values returned by OTGetEndpointState and OTSync
  661.     which represent the state of an endpoint
  662.     ------------------------------------------------------------------------- }
  663.     T_UNINIT                    = 0;                            { addition to standard xti.h    }
  664.     T_UNBND                        = 1;                            { unbound                        }
  665.     T_IDLE                        = 2;                            { idle                            }
  666.     T_OUTCON                    = 3;                            { outgoing connection pending    }
  667.     T_INCON                        = 4;                            { incoming connection pending    }
  668.     T_DATAXFER                    = 5;                            { data transfer                }
  669.     T_OUTREL                    = 6;                            { outgoing orderly release        }
  670.     T_INREL                        = 7;                            { incoming orderly release        }
  671.  
  672. {    -------------------------------------------------------------------------
  673.     Flags used by option management calls to request services
  674.     ------------------------------------------------------------------------- }
  675.     T_NEGOTIATE                    = $004;
  676.     T_CHECK                        = $008;
  677.     T_DEFAULT                    = $010;
  678.     T_CURRENT                    = $080;
  679.  
  680. {    -------------------------------------------------------------------------
  681.     Flags used by option management calls to return results
  682.     ------------------------------------------------------------------------- }
  683.     T_SUCCESS                    = $020;
  684.     T_FAILURE                    = $040;
  685.     T_PARTSUCCESS                = $100;
  686.     T_READONLY                    = $200;
  687.     T_NOTSUPPORT                = $400;
  688.  
  689. {    -------------------------------------------------------------------------
  690.     General definitions
  691.     ------------------------------------------------------------------------- }
  692.     T_YES                        = 1;
  693.     T_NO                        = 0;
  694.     T_UNUSED                    = -1;
  695.     T_NULL                        = 0;
  696.     T_ABSREQ                    = $8000;
  697.  
  698. {    -------------------------------------------------------------------------
  699.     Option Management definitions
  700.     ------------------------------------------------------------------------- }
  701.     T_UNSPEC                    = 0+($FFFFFFFF - 2);
  702.     T_ALLOPT                    = 0;
  703.  
  704. {}
  705. { This macro will align return the value of "len", rounded up to the next}
  706. { 4-byte boundary.}
  707. {}
  708.  
  709. TYPE
  710.     OTConfiguration = RECORD
  711.     END;
  712.     OTConfigurationPtr = ^OTConfiguration;
  713.  
  714.     t_kpalive = RECORD
  715.         kp_onoff:                LONGINT;                                { option on/off        }
  716.         kp_timeout:                LONGINT;                                { timeout in minutes    }
  717.     END;
  718.  
  719. {
  720.      * Structure used with XTI_LINGER option
  721.      }
  722.     t_linger = RECORD
  723.         l_onoff:                LONGINT;                                { option on/off }
  724.         l_linger:                LONGINT;                                { linger time }
  725.     END;
  726.  
  727. {    -------------------------------------------------------------------------
  728.     TEndpointInfo - this structure is returned from the GetEndpointInfo call
  729.     and contains information about an endpoint
  730.     ------------------------------------------------------------------------- }
  731.     TEndpointInfo = RECORD
  732.         addr:                    SInt32;                                    { Maximum size of an address            }
  733.         options:                SInt32;                                    { Maximum size of options                }
  734.         tsdu:                    SInt32;                                    { Standard data transmit unit size        }
  735.         etsdu:                    SInt32;                                    { Expedited data transmit unit size    }
  736.         connect:                SInt32;                                    { Maximum data size on connect            }
  737.         discon:                    SInt32;                                    { Maximum data size on disconnect        }
  738.         servtype:                UInt32;                                    { service type (see below for values)    }
  739.         flags:                    UInt32;                                    { Flags (see below for values)            }
  740.     END;
  741.  
  742. {
  743.      * Values returned in servtype field of TEndpointInfo
  744.      }
  745.  
  746. CONST
  747.     T_COTS                        = 1;                            { Connection-mode service                                }
  748.     T_COTS_ORD                    = 2;                            { Connection service with orderly release                }
  749.     T_CLTS                        = 3;                            { Connectionless-mode service                            }
  750.     T_TRANS                        = 5;                            { Connection-mode transaction service                    }
  751.     T_TRANS_ORD                    = 6;                            { Connection transaction service with orderly release    }
  752.     T_TRANS_CLTS                = 7;                            { Connectionless transaction service                    }
  753.  
  754. {
  755.      * Values returned in flags field of TEndpointInfo
  756.      }
  757.     T_SENDZERO                    = $001;                            { supports 0-length TSDU's            }
  758.     T_XPG4_1                    = $002;                            { supports the GetProtAddress call    }
  759.     T_CAN_SUPPORT_MDATA            = $10000000;                    { support M_DATAs on packet protocols    }
  760.     T_CAN_RESOLVE_ADDR            = $40000000;                    { Supports ResolveAddress call            }
  761.     T_CAN_SUPPLY_MIB            = $20000000;                    { Supports SNMP MIB data                }
  762.  
  763. {
  764.      * Values returned in tsdu, etsdu, connect, and discon fields of TEndpointInfo
  765.      }
  766.     T_INFINITE                    = -1;                            { supports infinit amounts of data        }
  767.     T_INVALID                    = -2;                            { Does not support data transmission    }
  768.  
  769. {    -------------------------------------------------------------------------
  770.     OTPortRecord
  771.     ------------------------------------------------------------------------- }
  772. {
  773.      * Unique identifier for a port
  774.      }
  775.     
  776. TYPE
  777.     OTPortRef = UInt32;
  778.  
  779. {
  780.      * A couple of special values for the "port type" in an OTPortRef.
  781.      * See OpenTptLinks.h for other values.
  782.      * The device kOTPseudoDevice is used where no other defined
  783.      * device type will work.
  784.      }
  785.  
  786. CONST
  787.     kOTNoDeviceType                = 0;
  788.     kOTPseudoDevice                = 1023;
  789.     kOTLastDeviceIndex            = 1022;
  790.     kOTLastSlotNumber            = 255;
  791.     kOTLastOtherNumber            = 255;
  792.  
  793. {
  794.      * kMaxPortNameLength is the maximum size allowed to define
  795.      * a port
  796.      }
  797.     kMaxPortNameLength            = kMaxModuleNameLength + 4;
  798.     kMaxPortNameSize            = kMaxPortNameLength + 1;
  799.  
  800.     kInvalidPortRef                = 0+(0);                        { %%% Going away }
  801.     kOTInvalidPortRef            = 0+(0);
  802.  
  803. {
  804.      * Equates for the legal Bus-type values
  805.      }
  806.     kOTUnknownBusPort            = 0;
  807.     kOTMotherboardBus            = 1;
  808.     kOTNuBus                    = 2;
  809.     kOTPCIBus                    = 3;
  810.     kOTGeoPort                    = 4;
  811.     kOTPCMCIABus                = 5;
  812.     kOTLastBusIndex                = 15;
  813.  
  814.  
  815. TYPE
  816.     OTPortCloseStruct = RECORD
  817.         fPortRef:                OTPortRef;                                { The port requested to be closed.}
  818.         fTheProvider:            ProviderRef;                            { The provider using the port.}
  819.         fDenyReason:            OSStatus;                                { Set to a negative number to deny the request}
  820.     END;
  821.  
  822.  
  823. FUNCTION OTCreatePortRef(busType: ByteParameter; devType: UInt16; slot: UInt16; other: UInt16): OTPortRef;
  824. FUNCTION OTGetDeviceTypeFromPortRef(ref: OTPortRef): UInt16;
  825. FUNCTION OTGetBusTypeFromPortRef(ref: OTPortRef): UInt16;
  826. FUNCTION OTGetSlotFromPortRef(ref: OTPortRef; VAR other: UInt16): UInt16;
  827.  
  828. TYPE
  829.     OTPortRecord = RECORD
  830.         fRef:                    OTPortRef;
  831.         fPortFlags:                UInt32;
  832.         fInfoFlags:                UInt32;
  833.         fCapabilities:            UInt32;
  834.         fNumChildPorts:            size_t;
  835.         fChildPorts:            ^OTPortRef;
  836.         fPortName:                PACKED ARRAY [0..kMaxProviderNameSize-1] OF CHAR;
  837.         fModuleName:            PACKED ARRAY [0..kMaxModuleNameSize-1] OF CHAR;
  838.         fSlotID:                PACKED ARRAY [0..kMaxSlotIDSize-1] OF CHAR;
  839.         fResourceInfo:            PACKED ARRAY [0..kMaxResourceInfoSize-1] OF CHAR;
  840.         fReserved:                PACKED ARRAY [0..163] OF CHAR;
  841.     END;
  842.  
  843. {
  844.      * Values for the fInfoFlags field of OTPortRecord
  845.      }
  846.  
  847. CONST
  848.     kOTPortIsDLPI                = $00000001;
  849.     kOTPortIsTPI                = $00000002;
  850.     kOTPortCanYield                = $00000004;
  851.     kOTPortIsSystemRegistered    = $00004000;
  852.     kOTPortIsPrivate            = $00008000;
  853.     kOTPortIsAlias                = $80000000;
  854.  
  855. {
  856.      * Values for the fPortFlags field of TPortRecord
  857.      * If no bits are set, the port is currently inactive.
  858.      * kOTPortIsDisabled and kOTPortIsUnavailable may be set
  859.      * at the same time.  
  860.      }
  861.     kOTPortIsActive                = $00000001;
  862.     kOTPortIsDisabled            = $00000002;
  863.     kOTPortIsUnavailable        = $00000004;
  864.  
  865. {    -------------------------------------------------------------------------
  866.     TOptionHeader and TOption
  867.     
  868.     This structure describes the contents of a single option in a buffer
  869.     ------------------------------------------------------------------------- }
  870.  
  871. TYPE
  872.     TOptionHeader = RECORD
  873.         len:                    UInt32;                                    { total length of option                }
  874.         { = sizeof(TOptionHeader) + length        }
  875.         {     of option value in bytes            }
  876.         level:                    OTXTILevel;                                { protocol affected                    }
  877.         optName:                OTXTIName;                                { option name                            }
  878.         status:                    UInt32;                                    { status value                            }
  879.     END;
  880.  
  881.     TOption = RECORD
  882.         len:                    UInt32;                                    { total length of option                }
  883.         { = sizeof(TOption) + length    }
  884.         {     of option value in bytes            }
  885.         level:                    OTXTILevel;                                { protocol affected                    }
  886.         optName:                OTXTIName;                                { option name                            }
  887.         status:                    UInt32;                                    { status value                            }
  888.         value:                    ARRAY [0..0] OF UInt32;                    { data goes here                        }
  889.     END;
  890.  
  891.  
  892. CONST
  893.     kOTOptionHeaderSize            = sizeof(TOptionHeader);
  894.     kOTBooleanOptionDataSize    = sizeof(UInt32);
  895.     kOTBooleanOptionSize        = kOTOptionHeaderSize + kOTBooleanOptionDataSize;
  896.     kOTOneByteOptionSize        = kOTOptionHeaderSize + 1;
  897.     kOTTwoByteOptionSize        = kOTOptionHeaderSize + 2;
  898.     kOTFourByteOptionSize        = kOTOptionHeaderSize + sizeof(UInt32);
  899.  
  900. {    -------------------------------------------------------------------------
  901.     PollRef structure
  902.     
  903.     This is used with the OTStreamPoll function
  904.     ------------------------------------------------------------------------- }
  905.  
  906. TYPE
  907.     PollRef = RECORD
  908.         filler:                    LONGINT;
  909.         events:                    INTEGER;
  910.         revents:                INTEGER;
  911.         ref:                    StreamRef;
  912.     END;
  913.  
  914. {    -------------------------------------------------------------------------
  915.     OTClientList structure
  916.     
  917.     This is used with the OTYieldPortRequest function.
  918.     ------------------------------------------------------------------------- }
  919.     OTClientList = RECORD
  920.         fNumClients:            size_t;
  921.         fBuffer:                PACKED ARRAY [0..3] OF SInt8; (* UInt8 *)
  922.     END;
  923.  
  924. {    -------------------------------------------------------------------------
  925.     OTData
  926.     
  927.     This is a structure that may be used in a TNetbuf or netbuf to send
  928.     non-contiguous data.  Set the 'len' field of the netbuf to the
  929.     constant kNetbufDataIsOTData to signal that the 'buf' field of the
  930.     netbuf actually points to one of these structures instead of a
  931.     memory buffer.
  932.     ------------------------------------------------------------------------- }
  933.     OTData = RECORD
  934.         fNext:                    Ptr;
  935.         fData:                    Ptr;
  936.         fLen:                    size_t;
  937.     END;
  938.  
  939.  
  940. CONST
  941.     kNetbufDataIsOTData            = $fffffffe;
  942.  
  943. {    -------------------------------------------------------------------------
  944.     OTBuffer
  945.  
  946.     This is the structure that is used for no-copy receives.
  947.     When you are done with it, you must call the OTReleaseBuffer function.
  948.     For best performance, you need to call OTReleaseBuffer quickly.  Only
  949.     data netbufs may use this - no netbufs for addresses or options, or the like.
  950.     ------------------------------------------------------------------------- }
  951.  
  952. TYPE
  953.     OTBuffer = RECORD
  954.         fLink:                    Ptr;                                    { b_next & b_prev}
  955.         fLink2:                    Ptr;
  956.         fNext:                    ^OTBuffer;                                { b_cont}
  957.         fData:                    ^UInt8;                                    { b_rptr}
  958.         fLen:                    size_t;                                    { b_wptr}
  959.         fSave:                    Ptr;                                    { b_datap}
  960.         fBand:                    SInt8; (* UInt8 *)                        { b_band}
  961.         fType:                    SInt8; (* UInt8 *)                        { b_pad1}
  962.         fPad1:                    SInt8; (* UInt8 *)
  963.         fFlags:                    SInt8; (* UInt8 *)                        { b_flag}
  964.     END;
  965.  
  966. {    -------------------------------------------------------------------------
  967.     OTBufferInfo
  968.     
  969.     This structure is used with OTReadBuffer to keep track of where you
  970.     are in the buffer, since the OTBuffer is "read-only".
  971.     ------------------------------------------------------------------------- }
  972.     OTBufferInfo = RECORD
  973.         fBuffer:                ^OTBuffer;
  974.         fOffset:                size_t;
  975.         fPad:                    SInt8; (* UInt8 *)
  976.         fFiller:                SInt8; (* UInt8 *)
  977.     END;
  978.  
  979.  
  980. CONST
  981.     kOTNetbufDataIsOTBufferStar    = $fffffffd;
  982.  
  983. {    -------------------------------------------------------------------------
  984.     TNetbuf
  985.     
  986.     This structure is the basic structure used to pass data back and forth
  987.     between the Open Transport protocols and their clients
  988.     ------------------------------------------------------------------------- }
  989.  
  990. TYPE
  991.     TNetbuf = RECORD
  992.         maxlen:                    size_t;
  993.         len:                    size_t;
  994.         buf:                    Ptr;
  995.     END;
  996.  
  997. {    -------------------------------------------------------------------------
  998.     TBind
  999.     
  1000.     Structure passed to GetProtAddress, ResolveAddress and Bind
  1001.     ------------------------------------------------------------------------- }
  1002.     TBind = RECORD
  1003.         addr:                    TNetbuf;
  1004.         qlen:                    OTQLen;
  1005.     END;
  1006.     TBindPtr = ^TBind;
  1007.  
  1008. {    -------------------------------------------------------------------------
  1009.     TDiscon
  1010.     
  1011.     Structure passed to RcvDisconnect to find out additional information
  1012.     about the disconnect
  1013.     ------------------------------------------------------------------------- }
  1014.     TDiscon = RECORD
  1015.         udata:                    TNetbuf;
  1016.         reason:                    OTReason;
  1017.         sequence:                OTSequence;
  1018.     END;
  1019.     TDisconPtr = ^TDiscon;
  1020.  
  1021. {    -------------------------------------------------------------------------
  1022.     TCall
  1023.     
  1024.     Structure passed to Connect, RcvConnect, Listen, Accept, and
  1025.     SndDisconnect to describe the connection.
  1026.     ------------------------------------------------------------------------- }
  1027.     TCall = RECORD
  1028.         addr:                    TNetbuf;
  1029.         opt:                    TNetbuf;
  1030.         udata:                    TNetbuf;
  1031.         sequence:                OTSequence;
  1032.     END;
  1033.  
  1034. {    -------------------------------------------------------------------------
  1035.     TUnitData
  1036.     
  1037.     Structure passed to SndUData and RcvUData to describe the datagram
  1038.     ------------------------------------------------------------------------- }
  1039.     TUnitData = RECORD
  1040.         addr:                    TNetbuf;
  1041.         opt:                    TNetbuf;
  1042.         udata:                    TNetbuf;
  1043.     END;
  1044.  
  1045. {    -------------------------------------------------------------------------
  1046.     TUDErr
  1047.     
  1048.     Structure passed to RcvUDErr to find out about a datagram error
  1049.     ------------------------------------------------------------------------- }
  1050.     TUDErr = RECORD
  1051.         addr:                    TNetbuf;
  1052.         opt:                    TNetbuf;
  1053.         error:                    SInt32;
  1054.     END;
  1055.  
  1056. {    -------------------------------------------------------------------------
  1057.     TOptMgmt
  1058.     
  1059.     Structure passed to the OptionManagement call to read or set protocol
  1060.     options.
  1061.     ------------------------------------------------------------------------- }
  1062.     TOptMgmt = RECORD
  1063.         opt:                    TNetbuf;
  1064.         flags:                    OTFlags;
  1065.     END;
  1066.  
  1067. {    -------------------------------------------------------------------------
  1068.     TRequest
  1069.     
  1070.     Structure passed to SndRequest and RcvRequest that contains the information
  1071.     about the request
  1072.     ------------------------------------------------------------------------- }
  1073.     TRequest = RECORD
  1074.         data:                    TNetbuf;
  1075.         opt:                    TNetbuf;
  1076.         sequence:                OTSequence;
  1077.     END;
  1078.  
  1079. {    -------------------------------------------------------------------------
  1080.     TReply
  1081.     
  1082.     Structure passed to SndReply to send a reply to an incoming request
  1083.     ------------------------------------------------------------------------- }
  1084.     TReply = RECORD
  1085.         data:                    TNetbuf;
  1086.         opt:                    TNetbuf;
  1087.         sequence:                OTSequence;
  1088.     END;
  1089.  
  1090. {    -------------------------------------------------------------------------
  1091.     TUnitRequest
  1092.     
  1093.     Structure passed to SndURequest and RcvURequest that contains the information
  1094.     about the request
  1095.     ------------------------------------------------------------------------- }
  1096.     TUnitRequest = RECORD
  1097.         addr:                    TNetbuf;
  1098.         opt:                    TNetbuf;
  1099.         udata:                    TNetbuf;
  1100.         sequence:                OTSequence;
  1101.     END;
  1102.  
  1103. {    -------------------------------------------------------------------------
  1104.     TUnitReply
  1105.     
  1106.     Structure passed to SndUReply to send a reply to an incoming request
  1107.     ------------------------------------------------------------------------- }
  1108.     TUnitReply = RECORD
  1109.         opt:                    TNetbuf;
  1110.         udata:                    TNetbuf;
  1111.         sequence:                OTSequence;
  1112.     END;
  1113.  
  1114. {    -------------------------------------------------------------------------
  1115.     TRegisterRequest
  1116.     ------------------------------------------------------------------------- }
  1117.     TRegisterRequest = RECORD
  1118.         name:                    TNetbuf;
  1119.         addr:                    TNetbuf;
  1120.         flags:                    OTFlags;
  1121.     END;
  1122.  
  1123. {    -------------------------------------------------------------------------
  1124.     TRegisterReply
  1125.     ------------------------------------------------------------------------- }
  1126.     TRegisterReply = RECORD
  1127.         addr:                    TNetbuf;
  1128.         nameid:                    OTNameID;
  1129.     END;
  1130.  
  1131. {    -------------------------------------------------------------------------
  1132.     TLookupRequest
  1133.     ------------------------------------------------------------------------- }
  1134.     TLookupRequest = RECORD
  1135.         name:                    TNetbuf;
  1136.         addr:                    TNetbuf;
  1137.         maxcnt:                    UInt32;
  1138.         timeout:                OTTimeout;
  1139.         flags:                    OTFlags;
  1140.     END;
  1141.  
  1142. {    -------------------------------------------------------------------------
  1143.     TLookupReply 
  1144.     
  1145.     Structure used by Mapper protocols to return the results of name Lookups
  1146.     ------------------------------------------------------------------------- }
  1147. {
  1148.      * This is the structure returned by the mapper for names that are
  1149.      * looked up.  
  1150.      }
  1151.     TLookupBuffer = RECORD
  1152.         fAddressLength:            UInt16;
  1153.         fNameLength:            UInt16;
  1154.         fAddressBuffer:            PACKED ARRAY [0..0] OF SInt8; (* UInt8 *)
  1155.     END;
  1156.  
  1157.     TLookupReply = RECORD
  1158.         names:                    TNetbuf;
  1159.         rspcount:                UInt32;
  1160.     END;
  1161.  
  1162. {******************************************************************************
  1163. ** C Interfaces to Open Transport
  1164. *******************************************************************************}
  1165. {    -------------------------------------------------------------------------
  1166.     Initializing and shutting down Open Transport
  1167.     ------------------------------------------------------------------------- }
  1168. {$IFC NOT OTKERNEL }
  1169.  
  1170. FUNCTION InitOpenTransport: OSStatus;
  1171. FUNCTION InitOpenTransportUtilities: OSStatus;
  1172. PROCEDURE CloseOpenTransport;
  1173. {}
  1174. { This registers yourself as a client for any miscellaneous Open Transport}
  1175. { notifications that come along. CloseOpenTransport will automatically do}
  1176. { an OTUnregisterAsClient, if you have not already done so.}
  1177. {}
  1178. FUNCTION OTRegisterAsClient(name: OTClientName; proc: OTNotifyProcPtr): OSStatus;
  1179. FUNCTION OTUnregisterAsClient: OSStatus;
  1180. {$ENDC}
  1181.  
  1182. PROCEDURE OTEnterInterrupt;
  1183. PROCEDURE OTLeaveInterrupt;
  1184. TYPE
  1185.     OTProcessProcPtr = ProcPtr;  { PROCEDURE (arg: UNIV Ptr); }
  1186.  
  1187.  
  1188. FUNCTION OTCreateDeferredTask(proc: OTProcessProcPtr; arg: UNIV Ptr): LONGINT;
  1189. FUNCTION OTScheduleDeferredTask(dtCookie: LONGINT): BOOLEAN;
  1190. FUNCTION OTScheduleInterruptTask(dtCookie: LONGINT): BOOLEAN;
  1191. FUNCTION OTDestroyDeferredTask(dtCookie: LONGINT): OSStatus;
  1192. {$IFC NOT OTKERNEL }
  1193. FUNCTION OTCreateSystemTask(proc: OTProcessProcPtr; arg: UNIV Ptr): LONGINT;
  1194. FUNCTION OTDestroySystemTask(stCookie: LONGINT): OSStatus;
  1195. FUNCTION OTScheduleSystemTask(stCookie: LONGINT): BOOLEAN;
  1196. FUNCTION OTCancelSystemTask(stCookie: LONGINT): BOOLEAN;
  1197. FUNCTION OTCanMakeSyncCall: BOOLEAN;
  1198. {$ENDC}
  1199. {$IFC NOT OTKERNEL }
  1200. FUNCTION OTGetIndexedPort(VAR record1: OTPortRecord; index: size_t): BOOLEAN;
  1201. FUNCTION OTFindPort(VAR record1: OTPortRecord; portName: ConstCStringPtr): BOOLEAN;
  1202. FUNCTION OTFindPortByRef(VAR record1: OTPortRecord; ref: OTPortRef): BOOLEAN;
  1203. {$ENDC}
  1204.  
  1205. TYPE
  1206.     strbuf = RECORD
  1207.         maxlen:                    LONGINT;                                { max buffer length }
  1208.         len:                    LONGINT;                                { length of data }
  1209.         buf:                    ^CHAR;                                    { pointer to buffer }
  1210.     END;
  1211.  
  1212. {$IFC NOT OTKERNEL }
  1213.  
  1214. FUNCTION OTCloseProvider(ref: ProviderRef): OSStatus;
  1215. FUNCTION OTTransferProviderOwnership(ref: ProviderRef; prevOwner: OTClient; VAR errPtr: OSStatus): ProviderRef;
  1216. FUNCTION OTWhoAmI: OTClient;
  1217. FUNCTION OTGetProviderPortRef(ref: ProviderRef): OTPortRef;
  1218. FUNCTION OTIoctl(ref: ProviderRef; cmd: UInt32; data: UNIV Ptr): SInt32;
  1219. FUNCTION OTGetMessage(ref: ProviderRef; VAR ctlbuf: strbuf; VAR databuf: strbuf; VAR flagPtr: OTFlags): OTResult;
  1220. FUNCTION OTGetPriorityMessage(ref: ProviderRef; VAR ctlbuf: strbuf; VAR databuf: strbuf; VAR bandPtr: OTBand; VAR flagPtr: OTFlags): OTResult;
  1221. FUNCTION OTPutMessage(ref: ProviderRef; {CONST}VAR ctlbuf: strbuf; {CONST}VAR databuf: strbuf; flags: OTFlags): OSStatus;
  1222. FUNCTION OTPutPriorityMessage(ref: ProviderRef; {CONST}VAR ctlbuf: strbuf; {CONST}VAR databuf: strbuf; band: OTBand; flags: OTFlags): OSStatus;
  1223. FUNCTION OTSetAsynchronous(ref: ProviderRef): OSStatus;
  1224. FUNCTION OTSetSynchronous(ref: ProviderRef): OSStatus;
  1225. FUNCTION OTIsSynchronous(ref: ProviderRef): BOOLEAN;
  1226. FUNCTION OTSetBlocking(ref: ProviderRef): OSStatus;
  1227. FUNCTION OTSetNonBlocking(ref: ProviderRef): OSStatus;
  1228. FUNCTION OTIsBlocking(ref: ProviderRef): BOOLEAN;
  1229. FUNCTION OTInstallNotifier(ref: ProviderRef; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1230. PROCEDURE OTRemoveNotifier(ref: ProviderRef);
  1231. FUNCTION OTAckSends(ref: ProviderRef): OSStatus;
  1232. FUNCTION OTDontAckSends(ref: ProviderRef): OSStatus;
  1233. FUNCTION OTIsAckingSends(ref: ProviderRef): BOOLEAN;
  1234. FUNCTION OTCancelSynchronousCalls(ref: ProviderRef; err: OSStatus): OSStatus;
  1235. {$ENDC}
  1236. {$IFC NOT OTKERNEL }
  1237.  
  1238. FUNCTION OTOpenEndpoint(config: OTConfigurationPtr; oflag: OTOpenFlags; VAR info: TEndpointInfo; VAR err: OSStatus): EndpointRef;
  1239. FUNCTION OTAsyncOpenEndpoint(config: OTConfigurationPtr; oflag: OTOpenFlags; VAR info: TEndpointInfo; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1240. {}
  1241. { Misc Information}
  1242. {}
  1243. FUNCTION OTGetEndpointInfo(ref: EndpointRef; VAR info: TEndpointInfo): OSStatus;
  1244. FUNCTION OTGetEndpointState(ref: EndpointRef): OTResult;
  1245. FUNCTION OTLook(ref: EndpointRef): OTResult;
  1246. FUNCTION OTSync(ref: EndpointRef): OTResult;
  1247. FUNCTION OTCountDataBytes(ref: EndpointRef; VAR countPtr: size_t): OTResult;
  1248. FUNCTION OTGetProtAddress(ref: EndpointRef; VAR boundAddr: TBind; VAR peerAddr: TBind): OSStatus;
  1249. FUNCTION OTResolveAddress(ref: EndpointRef; VAR reqAddr: TBind; VAR retAddr: TBind; timeOut: OTTimeout): OSStatus;
  1250. {}
  1251. { Allocating structures}
  1252. {}
  1253. FUNCTION OTAlloc(ref: EndpointRef; structType: OTStructType; fields: UInt32; VAR err: OSStatus): Ptr;
  1254. FUNCTION OTFree(ptr: UNIV Ptr; structType: OTStructType): OTResult;
  1255. {}
  1256. { Option management}
  1257. {}
  1258. FUNCTION OTOptionManagement(ref: EndpointRef; VAR req: TOptMgmt; VAR ret: TOptMgmt): OSStatus;
  1259. {}
  1260. { Bind/Unbind}
  1261. {}
  1262. FUNCTION OTBind(ref: EndpointRef; reqAddr: TBindPtr; retAddr: TBindPtr): OSStatus;
  1263. FUNCTION OTUnbind(ref: EndpointRef): OSStatus;
  1264. {}
  1265. { Connection creation/tear-down}
  1266. {}
  1267. FUNCTION OTConnect(ref: EndpointRef; VAR sndCall: TCall; VAR rcvCall: TCall): OSStatus;
  1268. FUNCTION OTRcvConnect(ref: EndpointRef; VAR call: TCall): OSStatus;
  1269. FUNCTION OTListen(ref: EndpointRef; VAR call: TCall): OSStatus;
  1270. FUNCTION OTAccept(ref: EndpointRef; resRef: EndpointRef; VAR call: TCall): OSStatus;
  1271. FUNCTION OTSndDisconnect(ref: EndpointRef; VAR call: TCall): OSStatus;
  1272. FUNCTION OTSndOrderlyDisconnect(ref: EndpointRef): OSStatus;
  1273. FUNCTION OTRcvDisconnect(ref: EndpointRef; discon: TDisconPtr): OSStatus;
  1274. FUNCTION OTRcvOrderlyDisconnect(ref: EndpointRef): OSStatus;
  1275. {}
  1276. { Connection-oriented send/receive}
  1277. {}
  1278. FUNCTION OTRcv(ref: EndpointRef; buf: UNIV Ptr; nbytes: size_t; VAR flags: OTFlags): OTResult;
  1279. FUNCTION OTSnd(ref: EndpointRef; buf: UNIV Ptr; nbytes: size_t; flags: OTFlags): OTResult;
  1280. {}
  1281. { non-connection oriented send/receive}
  1282. {}
  1283. FUNCTION OTSndUData(ref: EndpointRef; VAR udata: TUnitData): OSStatus;
  1284. FUNCTION OTRcvUData(ref: EndpointRef; VAR udata: TUnitData; VAR flags: OTFlags): OSStatus;
  1285. FUNCTION OTRcvUDErr(ref: EndpointRef; VAR uderr: TUDErr): OSStatus;
  1286. {}
  1287. { Connection-oriented transactions}
  1288. {}
  1289. FUNCTION OTSndRequest(ref: EndpointRef; VAR req: TRequest; reqFlags: OTFlags): OSStatus;
  1290. FUNCTION OTRcvReply(ref: EndpointRef; VAR reply: TReply; VAR replyFlags: OTFlags): OSStatus;
  1291. FUNCTION OTSndReply(ref: EndpointRef; VAR reply: TReply; replyFlags: OTFlags): OSStatus;
  1292. FUNCTION OTRcvRequest(ref: EndpointRef; VAR req: TRequest; VAR reqFlags: OTFlags): OSStatus;
  1293. FUNCTION OTCancelRequest(ref: EndpointRef; sequence: OTSequence): OSStatus;
  1294. FUNCTION OTCancelReply(ref: EndpointRef; sequence: OTSequence): OSStatus;
  1295. {}
  1296. { Connectionless transactions}
  1297. {}
  1298. FUNCTION OTSndURequest(ref: EndpointRef; VAR req: TUnitRequest; reqFlags: OTFlags): OSStatus;
  1299. FUNCTION OTRcvUReply(ref: EndpointRef; VAR reply: TUnitReply; VAR replyFlags: OTFlags): OSStatus;
  1300. FUNCTION OTSndUReply(ref: EndpointRef; VAR reply: TUnitReply; replyFlags: OTFlags): OSStatus;
  1301. FUNCTION OTRcvURequest(ref: EndpointRef; VAR req: TUnitRequest; VAR reqFlags: OTFlags): OSStatus;
  1302. FUNCTION OTCancelURequest(ref: EndpointRef; seq: OTSequence): OSStatus;
  1303. FUNCTION OTCancelUReply(ref: EndpointRef; seq: OTSequence): OSStatus;
  1304. {    -------------------------------------------------------------------------
  1305.     Interface to mappers
  1306.     ------------------------------------------------------------------------- }
  1307. FUNCTION OTAsyncOpenMapper(VAR config: OTConfiguration; oflag: OTOpenFlags; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1308. FUNCTION OTOpenMapper(VAR config: OTConfiguration; oflag: OTOpenFlags; VAR err: OSStatus): MapperRef;
  1309. FUNCTION OTRegisterName(ref: MapperRef; VAR req: TRegisterRequest; VAR reply: TRegisterReply): OSStatus;
  1310. FUNCTION OTDeleteName(ref: MapperRef; VAR name: TNetbuf): OSStatus;
  1311. FUNCTION OTDeleteNameByID(ref: MapperRef; nameID: OTNameID): OSStatus;
  1312. FUNCTION OTLookupName(ref: MapperRef; VAR req: TLookupRequest; VAR reply: TLookupReply): OSStatus;
  1313. {    -------------------------------------------------------------------------
  1314.     Miscellaneous and generic functions
  1315.     ------------------------------------------------------------------------- }
  1316. FUNCTION OTAllocMem(size: size_t): Ptr; C;
  1317. PROCEDURE OTFreeMem(memptr: UNIV Ptr); C;
  1318. PROCEDURE OTDelay(seconds: UInt32);
  1319. PROCEDURE OTIdle;
  1320.     
  1321. FUNCTION OTCreateConfiguration(path: ConstCStringPtr): OTConfigurationPtr;
  1322. FUNCTION OTCloneConfiguration(cfig: OTConfigurationPtr): OTConfigurationPtr;
  1323. PROCEDURE OTDestroyConfiguration(cfig: OTConfigurationPtr);
  1324. FUNCTION OTCreateOptions(endPtName: ConstCStringPtr; strPtr: CStringPtr; VAR buf: TNetbuf): OSStatus;
  1325. FUNCTION OTCreateOptionString(endPtName: ConstCStringPtr; VAR opt: TOption; bufEnd: UNIV Ptr; strPTr: CStringPtr; stringSize: size_t): OSStatus;
  1326. FUNCTION OTNextOption(VAR buffer: UInt8; buflen: UInt32; VAR prevOptPtr: TOption): OSStatus;
  1327.     
  1328. TYPE
  1329.     TOptionPtr = ^TOption;
  1330.  
  1331.  
  1332. FUNCTION OTFindOption(VAR buffer: UInt8; buflen: UInt32; level: OTXTILevel; name: OTXTIName): TOptionPtr;
  1333. {$ENDC}
  1334.  
  1335. PROCEDURE OTMemcpy(dest: UNIV Ptr; src: UNIV Ptr; nBytes: size_t); C;
  1336. FUNCTION OTMemcmp(mem1: UNIV Ptr; mem2: UNIV Ptr; nBytes: size_t): BOOLEAN; C;
  1337. PROCEDURE OTMemmove(dest: UNIV Ptr; src: UNIV Ptr; nBytes: size_t); C;
  1338. PROCEDURE OTMemzero(dest: UNIV Ptr; nBytes: size_t); C;
  1339. PROCEDURE OTMemset(dest: UNIV Ptr; toSet: uchar_p; nBytes: size_t); C;
  1340. FUNCTION OTStrLength(strPtr: ConstCStringPtr): size_t; C;
  1341. PROCEDURE OTStrCopy(strTo: CStringPtr; strFrom: ConstCStringPtr); C;
  1342. PROCEDURE OTStrCat(strTo: CStringPtr; strFrom: ConstCStringPtr); C;
  1343. FUNCTION OTStrEqual(strPtr1: ConstCStringPtr; strPtr2: ConstCStringPtr): BOOLEAN; C;
  1344. {    -------------------------------------------------------------------------
  1345.     ** Time functions
  1346.     **    
  1347.     **    OTGetTimeStamp returns time in "tick" numbers, stored in 64 bits.
  1348.     **    This timestamp can be used as a base number for calculating elapsed 
  1349.     **    time.
  1350.     **    OTSubtractTimeStamps returns a pointer to the "result" parameter.
  1351.     **        
  1352.     **    OTGetClockTimeInSecs returns time since Open Transport was initialized
  1353.     **        in seconds.
  1354.     ------------------------------------------------------------------------- }
  1355.     
  1356. TYPE
  1357.     OTTimeStamp = UnsignedWide;
  1358.  
  1359.     OTTimeStampPtr = ^OTTimeStamp;
  1360.  
  1361.  
  1362. PROCEDURE OTGetTimeStamp(VAR stamp: OTTimeStamp); C;
  1363. FUNCTION OTSubtractTimeStamps(VAR result: OTTimeStamp; VAR startTime: OTTimeStamp; VAR endTime: OTTimeStamp): OTTimeStampPtr; C;
  1364. FUNCTION OTTimeStampInMilliseconds(VAR delta: OTTimeStamp): UInt32; C;
  1365. FUNCTION OTTimeStampInMicroseconds(VAR delta: OTTimeStamp): UInt32; C;
  1366. FUNCTION OTElapsedMilliseconds(VAR startTime: OTTimeStamp): UInt32; C;
  1367. FUNCTION OTElapsedMicroseconds(VAR startTime: OTTimeStamp): UInt32; C;
  1368. FUNCTION OTGetClockTimeInSecs: UInt32; C;
  1369. {    -------------------------------------------------------------------------
  1370.     ** OTLIFO
  1371.     **
  1372.     ** These are functions to implement a LIFO list that is interrupt-safe.
  1373.     ** The only function which is not is OTReverseList.  Normally, you create
  1374.     ** a LIFO list, populate it at interrupt time, and then use OTLIFOStealList
  1375.     ** to atomically remove the list, and OTReverseList to flip the list so that
  1376.     ** it is a FIFO list, which tends to be more useful.
  1377.     ------------------------------------------------------------------------- }
  1378.     
  1379. TYPE
  1380.     OTLinkPtr = ^OTLink;
  1381.  
  1382.     OTLIFO = RECORD
  1383.         fHead:                    ^OTLink;
  1384.     END;
  1385.  
  1386.     OTLink = RECORD
  1387.         fNext:                    ^OTLink;
  1388.     END;
  1389.  
  1390. {}
  1391. { This function puts "object" on the listHead, and places the}
  1392. { previous value at listHead into the pointer at "object" plus}
  1393. { linkOffset.}
  1394. {}
  1395.  
  1396. PROCEDURE OTEnqueue(listHead: UNIV Ptr; object: UNIV Ptr; linkOffset: size_t); C;
  1397. {}
  1398. { This function returns the head object of the list, and places}
  1399. { the pointer at "object" + linkOffset into the listHead}
  1400. {}
  1401. FUNCTION OTDequeue(listHead: UNIV Ptr; linkOffset: size_t): Ptr; C;
  1402. {}
  1403. { This function atomically enqueues the link onto the list}
  1404. {}
  1405. PROCEDURE OTLIFOEnqueue(VAR list: OTLIFO; VAR link: OTLink); C;
  1406. {}
  1407. { This function atomically dequeues the first element}
  1408. { on the list}
  1409. {}
  1410. FUNCTION OTLIFODequeue(VAR list: OTLIFO): OTLinkPtr; C;
  1411. FUNCTION OTLIFOStealList(VAR list: OTLIFO): OTLinkPtr; C;
  1412. FUNCTION OTReverseList(VAR list: OTLink): OTLinkPtr; C;
  1413.  
  1414. TYPE
  1415.     OTList = RECORD
  1416.         fHead:                    ^OTLink;
  1417.     END;
  1418.  
  1419.     OTListSearchProcPtr = ProcPtr;  { FUNCTION (ref: UNIV Ptr; VAR linkToCheck: OTLink): BOOLEAN; }
  1420.  
  1421. {}
  1422. { Add the link to the list at the front}
  1423. {}
  1424.  
  1425. PROCEDURE OTAddFirst(VAR list: OTList; VAR link: OTLink); C;
  1426. {}
  1427. { Add the link to the list at the end}
  1428. {}
  1429. PROCEDURE OTAddLast(VAR list: OTList; VAR link: OTLink); C;
  1430. {}
  1431. { Remove the first link from the list}
  1432. {}
  1433. FUNCTION OTRemoveFirst(VAR list: OTList): OTLinkPtr; C;
  1434. FUNCTION OTRemoveLast(VAR list: OTList): OTLinkPtr; C;
  1435. FUNCTION OTGetFirst(VAR list: OTList): OTLinkPtr; C;
  1436. FUNCTION OTGetLast(VAR list: OTList): OTLinkPtr; C;
  1437. FUNCTION OTIsInList(VAR list: OTList; VAR link: OTLink): BOOLEAN; C;
  1438. {}
  1439. { Find a link in the list which matches the search criteria}
  1440. { established by the search proc and the refPtr.  This is done}
  1441. { by calling the search proc, passing it the refPtr and each}
  1442. { link in the list, until the search proc returns true.}
  1443. { NULL is returned if the search proc never returned true.}
  1444. {}
  1445. FUNCTION OTFindLink(VAR listPtr: OTList; procPtr: OTListSearchProcPtr; refPtr: UNIV Ptr): OTLink; C;
  1446. {}
  1447. { Remove the specified link from the list, returning true if it was found}
  1448. {}
  1449. FUNCTION OTRemoveLink(VAR listPtr: OTList; VAR linkPtr: OTLink): BOOLEAN; C;
  1450. {}
  1451. { Similar to OTFindLink, but it also removes it from the list.}
  1452. {}
  1453. FUNCTION OTFindAndRemoveLink(VAR list: OTList; proc: OTListSearchProcPtr; refPtr: UNIV Ptr): OTLinkPtr; C;
  1454. FUNCTION OTGetIndexedLink(VAR list: OTList; index: size_t): OTLinkPtr; C;
  1455.     
  1456. TYPE
  1457.     OTLock = UInt8;
  1458.  
  1459.  
  1460. FUNCTION OTAtomicSetBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1461. FUNCTION OTAtomicClearBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1462. FUNCTION OTAtomicTestBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1463. {}
  1464. { WARNING! void* and UInt32 locations MUST be on 4-byte boundaries.}
  1465. {            UInt16 locations must not cross a 4-byte boundary.}
  1466. {}
  1467. FUNCTION OTCompareAndSwapPtr(oldValue: UNIV Ptr; newValue: UNIV Ptr; location: UNIV Ptr): BOOLEAN; C;
  1468. FUNCTION OTCompareAndSwap32(oldValue: UInt32; newValue: UInt32; VAR location: UInt32): BOOLEAN; C;
  1469. FUNCTION OTCompareAndSwap16(oldValue: UInt32; newValue: UInt32; VAR location: UInt16): BOOLEAN; C;
  1470. FUNCTION OTCompareAndSwap8(oldValue: UInt32; newValue: UInt32; VAR location: UInt8): BOOLEAN; C;
  1471. {}
  1472. { WARNING! UInt32 locations MUST be on 4-byte boundaries.}
  1473. {            UInt16 locations must not cross a 4-byte boundary.}
  1474. {}
  1475. FUNCTION OTAtomicAdd32(val: SInt32; VAR ptr: SInt32): SInt32; C;
  1476. FUNCTION OTAtomicAdd16(val: SInt16; VAR ptr: SInt16): SInt16; C;
  1477. FUNCTION OTAtomicAdd8(val: ByteParameter; VAR ptr: SInt8): SInt8; C;
  1478.  
  1479. {$ALIGN RESET}
  1480. {$POP}
  1481.  
  1482. {$SETC UsingIncludes := OpenTransportIncludes}
  1483.  
  1484. {$ENDC} {__OPENTRANSPORT__}
  1485.  
  1486. {$IFC NOT UsingIncludes}
  1487.  END.
  1488. {$ENDC}
  1489.